package com.myhkvideo.yulongbpcdemo.Scheduler;



import com.myhkvideo.yulongbpcdemo.service.DataExportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Timer;

@Component
public class DataExportScheduler {

    @Autowired
    private DataExportService dataExportService;

    // 每小时执行一次
    @Scheduled(fixedRate = 3600000) // 3600000 毫秒 = 1 小时
    public void runDataExportTask() {
        Timer timer = new Timer();
        System.out.println("数据文件输出定时任务开始执行");
        timer.scheduleAtFixedRate(new DataExportService.DataExportTimerTask(), 0, 3600 * 1000);
        System.out.println("数据文件输出定时任务执行结束");

    }
}